package com.asistencia.businness;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.asistencia.dao.interfaces.ProfessorCourseDao;
import com.asistencia.domain.ProfessorCourse;

@Service
public class ProfessorCourseBusiness {

        @Autowired
        private ProfessorCourseDao professorCourseDao;
        @Autowired
        private ProfessorCourse professorCourse;
        
        public List<ProfessorCourse> listSemestersByIdProfesor(Integer idProfessor){
                return professorCourseDao.listSemestersByProfessor(idProfessor);
        }

        public ProfessorCourse getById(Integer idProfesssorCourse) {
                try {
                        professorCourse = professorCourseDao.getById(idProfesssorCourse);
                        return professorCourse;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listAll() {
                try {
                        professorCourseDao.listAll();
                        List<ProfessorCourse> lstAll = professorCourseDao.listAll();
                        return lstAll;
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listProfessorCourseByProfessorSemester(Integer idProfessor,Integer idSemester) {
                try {
                        return professorCourseDao.listByProfessorSemester(idProfessor, idSemester);
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listByIdSemester(Integer idSemester) {
                try {
                        professorCourseDao.listByIdSemester(idSemester);
                        List<ProfessorCourse> lstPro = professorCourseDao.listByIdSemester(idSemester);
                        return lstPro;
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listByIdCourses(Integer idCourse) {
                try {
                        professorCourseDao.listByIdSemester(idCourse);
                        List<ProfessorCourse> lstCour = professorCourseDao.listByIdCourse(idCourse);
                        return lstCour;
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listByIdProfessor(Integer idProfessor) {
                try {
                        professorCourseDao.listByIdSemester(idProfessor);
                        List<ProfessorCourse> lstidPro = professorCourseDao.listByIdProfessor(idProfessor);
                        return lstidPro;
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

        public List<ProfessorCourse> listbyProfessorCourses(Integer idProfessor, Integer idCourse) {
                try {
                        professorCourseDao.listByIdSemester(idProfessor);
                        List<ProfessorCourse> lstProfes = professorCourseDao.listByProfessorCourse(idProfessor,
                                        idCourse);
                        return lstProfes;
                }
                catch (DataAccessException e) {
                        e.printStackTrace();
                        return null;
                }
                catch (Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }

}